<?

    include_once './functions.php';
    
    // Ouverture flux NNTP
    //$result = imap_open("{news.free.fr:119/nntp}fr.rec.humour.selection",'stanislas.perrin','f1sls-2');
    $result = imap_open("{news.free.fr:119/nntp}fr.rec.radio.amateur",'stanislas.perrin','f1sls-2');
    
    $chk = imap_check($result);
    
    echo '<pre>';
    var_dump($chk);
    echo '</pre>';
    
    // 10 derniers messages
    $lastMessageId = $chk->Recent;
    
    for ($i=0;$i<=10;$i++)
    {
        $messageId = $lastMessageId - $i;
        $messages[$messageId]['header'] = imap_fetchheader($result,$messageId);
        $messages[$messageId]['body'] = imap_body($result,$messageId);
    }
    
    /*
    echo '<pre>';
    var_dump($messages);
    echo '</pre>';
    */
    
    foreach($messages as $message)
    {
        $h = parseHeader($message['header']);
        $b = nl2br($message['body']);
        
        foreach($h as $hName => $hContent)
        {
            echo "<br />$hName ==> $hContent";
        }
        
        echo "<br /><br />$b<br/><br />";
    }
    
    imap_close($result);

?>